package util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class BaseUtil {
	public static String toCrawl(String name, List<String> set){
		for(String s : set){
			name = name.toUpperCase().trim();
			String s1 = s.toUpperCase().trim();
			if (name.contains(s1)){
				return s;
			}
		}
		return "";
	}

	public static List<String> readFileText(String filePath, String encode){
		List<String> lines = new ArrayList<>();
        try {
            File file=new File(filePath);
            if(file.isFile() && file.exists()){ //判断文件是否存在
                InputStreamReader read = new InputStreamReader(
                new FileInputStream(file),encode);//考虑到编码格式
                BufferedReader bufferedReader = new BufferedReader(read);
                String lineTxt = "";
                while((lineTxt = bufferedReader.readLine()) != null){
                   	lines.add(lineTxt);
                }
                read.close();
	        }else{
	            System.out.println("找不到指定的文件");
	        }
        } catch (Exception e) {
            System.out.println("读取文件内容出错");
            e.printStackTrace();
        }
        return lines;
	}
	
	public static void main(String[] args) {
		System.out.println("APPLE/".contains("APPLE"));
		System.out.println("APPLE/苹果".toUpperCase().contains("apple".toUpperCase()));
	}
}
